package com.itheima.consultant.controller;

import com.itheima.consultant.config.aiservice.ConsultantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
public class ChatController {
    @Autowired
    private ConsultantService consultantService;

    //流式
    @RequestMapping(value = "/chat",produces = "text/html;charset=utf-8")
    public Flux<String> chat(String memoryId,String message){
        Flux<String> result = consultantService.chat(memoryId,message);
        return result;
    }

    //非流式
    @RequestMapping(value = "/chat-unflex",produces = "text/html;charset=utf-8")
    public String chat_unflex(String memoryId,String message){
        String result = consultantService.chat_unflex(memoryId,message);
        return result;
    }



    //简单调用，不做任何配置（此时ConsultantService只需要配置在CommonConfig中，不用独立出来）
    /*@Autowired
    private OpenAiChatModel model;
    @RequestMapping("/chat")
    public String chat(String message){//浏览器传递的用户问题
        String result = model.chat(message);
        return result;
    }*/
}
